
function OcrMlkit() {
    this._ocr = undefined;
}

OcrMlkit.prototype.init = function () {
    let MLKitOCR = $plugins.load('org.autojs.autojspro.plugin.mlkit.ocr');
    this._ocr = new MLKitOCR();
}

OcrMlkit.prototype.ocr = function () {
    if(!this._ocr){
        this.init()
    }
    // const ocr = $ocr.create({
    //     models: 'default', // Specify the model with relatively high precision but slower speed
    // });
    let capture = captureScreen();

    // Detect text in the screenshot and calculate detection time
    const start = Date.now();
    const result = this._ocr.detect(capture);
    const end = Date.now();

    console.log(result);
    console.log('Screenshot detection time: ' + (end - start) + 'ms');
    return result;
}


module.exports = new OcrMlkit();
